package servlet;

import bo.UserBO;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javabean.UserBean;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name = "ListAllUserServlet", urlPatterns = {"/ListAllUserServlet"})
public class ListAllUserServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            UserBO userBO = new UserBO();
            ArrayList<UserBean> allUsers = userBO.listAllUser();
            req.setAttribute("allUsers", allUsers);
            RequestDispatcher dist = req.getRequestDispatcher("./jsp/Account/ListUsers.jsp");
            dist.forward(req, resp);

        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}
